<template>
  <el-dialog
    title="添加"
    :visible.sync="resetPwdVisible"
    :before-close="close"
    :close-on-click-modal="false"
    width="30%"
    top="5vh"
  >
    <el-form ref="form" :model="form" label-width="100px">
      <el-form-item label="密码" prop="password" required>
        <el-input
          v-model="form.password"
          placeholder="密码"
          style="width: 100%"
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取消</el-button>
      <el-button type="primary" @click="save">保存</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      form: {
        password: "",
      },
    };
  },
  props: {
    resetPwdVisible: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    close() {
      this.form = {
        password: "",
      };
      this.$emit("hideResetPwd");
    },
    save() {
      if (this.form.password == "") {
        this.$message.warning("密码不能为空");
        return;
      }
      this.$axios.post("/user/resetpwd", this.form).then((res) => {
        debugger;
        if (res.data.code != 0) {
          this.$message.error(res.data.msg);
        } else {
          this.close();
          this.$emit("logout");
        }
      });
    },
  },
  mounted() {},
};
</script>

<style>
</style>